#ifndef IMAGEMODEL_H
#define IMAGEMODEL_H

#include <QAbstractItemModel>
#include <QBitmap>
#include <QPixmap>
struct IMAGE{
    QPixmap pixFile;
    QString strText;
    QString strPath;
    bool bSelect;
};

class ImageModel : public QAbstractListModel
{
    Q_OBJECT
public:
    static ImageModel * getInstance();
    enum Roles{
        TextRole = Qt::UserRole+1,
        PathRole,
        SelectRole
    };
    
    // 插入新图片
    void insertImage(const QString& imagePath);
    // 删除选中的图片
    void deleteSelectedImages();
    void setSelect(int nIndex, bool select);
    // 全选/取消全选
    void selectAll(bool select);
    int rowCount(const QModelIndex &parent) const;
private:
    explicit ImageModel(QObject *parent = nullptr);
    QVariant data(const QModelIndex &index, int role) const;
    QVector<IMAGE> m_list;
    static ImageModel * m_pInstance;
};

#endif // IMAGEMODEL_H
